package com.shwread.android.qysw.step.model;

import com.ciko.code.bean.User;
import com.shwread.android.qysw.step.dto.HMUserInfo;
import com.shwread.android.qysw.tools.DataKeeperHelper;

/**
 * Created by Fantasy on 16/4/1.
 */
public class UserHealthyModel {
    public User user;
    private static final String TAG_USER_INFO = "tag_user_info";
    public HMUserInfo hmUserInfo;
    public boolean isHasSensor = false;
    public boolean isFirstUse =false;
    private static class UserHealthyModelHolder {
        public final static UserHealthyModel sington = new UserHealthyModel();
    }

    public static UserHealthyModel getInstance() {
        return UserHealthyModelHolder.sington;
    }

    private UserHealthyModel() {
        tryLoadLocal();
    }

    private boolean tryLoadLocal() {
        hmUserInfo = (HMUserInfo) DataKeeperHelper.getInstance().getUserInfoCache().get(TAG_USER_INFO);
        return hmUserInfo != null;
    }

    public void setMyHmUserInfo(HMUserInfo hmUserInfo) {
        DataKeeperHelper.getInstance().getUserInfoCache().put(TAG_USER_INFO, hmUserInfo);
    }

    public HMUserInfo getMyHmUserInfo() {
        return hmUserInfo = (HMUserInfo) DataKeeperHelper.getInstance().getUserInfoCache().get(TAG_USER_INFO);
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public void setHasSensor() {
        DataKeeperHelper.getInstance().getUserInfoCache().put("has_sensor", true);
    }

    public boolean getHasSensor() {
        return DataKeeperHelper.getInstance().getUserInfoCache().get("has_sensor", false);
    }

    public boolean isFirstUse() {
        return DataKeeperHelper.getInstance().getUserInfoCache().get("first_use", true);
    }

    public void setIsFirstUse(boolean isFirstUse) {
        DataKeeperHelper.getInstance().getUserInfoCache().put("first_use", isFirstUse);
    }
}
